package com.gitee.free.coding.core.exceptions;

import com.gitee.free.coding.core.enums.ErrorEnum;
import lombok.Getter;

@Getter
public class FreeRuntimeException extends RuntimeException {

    /**
     * 异常编码
     */
    private final Integer errorCode;

    /**
     * 异常信息
     */
    private final String errorMsg;

    public FreeRuntimeException(Integer errorCode, String errorMsg) {
        super("[errorCode = " + errorCode + ", errorMsg = " + errorMsg + "]");
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public FreeRuntimeException(ErrorEnum errorEnum) {
        super("[errorCode = " + errorEnum.getErrorCode() + ", errorMsg = " + errorEnum.getErrorMsg() + "]");
        this.errorCode = errorEnum.getErrorCode();
        this.errorMsg = errorEnum.getErrorMsg();
    }

}
